package pCloud.message;

import java.io.Serializable;
import java.net.InetSocketAddress;
import java.util.ArrayList;

public class RequestedResource implements Serializable {
	String name, role;
	InetSocketAddress host;
	String databaseId, tableId;
	String dataId; 
	String constrain, action;
	ArrayList<String> columnIds;
	String[] inputValues = null;
	String joiningColumn = null;

	public RequestedResource(String name, String role, InetSocketAddress host,
			String databaseId, String tableId, String constrain, String action, String[] inputVal) {
		this.name = name;
		this.role = role;
		this.host = host;
		this.databaseId = databaseId;
		this.tableId = tableId;
		this.columnIds = new ArrayList<String>();
		this.constrain = constrain;
		this.action = action;
		this.inputValues = inputVal;
	}
	


	public RequestedResource(String name, String role, String dataId,
			String tableId, String constrain, String action, String[] inputVal) {
		this.name = name;
		this.role = role;
		this.dataId = dataId;
		this.tableId = tableId;
		this.columnIds = new ArrayList<String>();
		this.constrain = constrain;
		this.action = action;
		this.inputValues = inputVal;
	}

	public String[] getInputValues(){
		return this.inputValues;
	}
	
	public String getDataId(){
		return this.dataId;
	}
	
	public void addColumnId(String columnId) {
		this.columnIds.add(columnId);
	}

	public void addJoiningColumn(String joiningColumn) {
		this.joiningColumn = joiningColumn;
	}

	public String getJoiningColumn() {
		return this.joiningColumn;
	}

	public void setHost(InetSocketAddress host){
		this.host = host;
	}
	
	public InetSocketAddress getHost() {
		return host;
	}

	public void setDatabaseId(String id){
		this.databaseId = id;
	}
	
	public String getDatabaseId() {
		return databaseId;
	}

	public String getTableId() {
		return tableId;
	}

	public ArrayList<String> getColumnIds() {
		return columnIds;
	}

	public String getConstrain() {
		return constrain;
	}

	public String getAction() {
		return this.action;
	}

	public String getName() {
		return this.name;
	}

	public String getRole() {
		return this.role;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((action == null) ? 0 : action.hashCode());
		result = prime * result
				+ ((columnIds == null) ? 0 : columnIds.hashCode());
		result = prime * result
				+ ((constrain == null) ? 0 : constrain.hashCode());
		result = prime * result
				+ ((databaseId == null) ? 0 : databaseId.hashCode());
		result = prime * result + ((host == null) ? 0 : host.hashCode());
		result = prime * result
				+ ((joiningColumn == null) ? 0 : joiningColumn.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((role == null) ? 0 : role.hashCode());
		result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		RequestedResource other = (RequestedResource) obj;
		if (action == null) {
			if (other.action != null)
				return false;
		} else if (!action.equals(other.action))
			return false;
		if (columnIds == null) {
			if (other.columnIds != null)
				return false;
		} else if (!columnIds.equals(other.columnIds))
			return false;
		if (constrain == null) {
			if (other.constrain != null)
				return false;
		} else if (!constrain.equals(other.constrain))
			return false;
		if (databaseId == null) {
			if (other.databaseId != null)
				return false;
		} else if (!databaseId.equals(other.databaseId))
			return false;
		if (host == null) {
			if (other.host != null)
				return false;
		} else if (!host.equals(other.host))
			return false;
		if (joiningColumn == null) {
			if (other.joiningColumn != null)
				return false;
		} else if (!joiningColumn.equals(other.joiningColumn))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (role == null) {
			if (other.role != null)
				return false;
		} else if (!role.equals(other.role))
			return false;
		if (tableId == null) {
			if (other.tableId != null)
				return false;
		} else if (!tableId.equals(other.tableId))
			return false;
		return true;
	}
}
